Skip to content

core::num::f16b Rust's 16bit Brain Float - #160859

Open
Jamesbarford wants to merge 17 commits into
rust-lang:mainfrom
Jamesbarford:feat/fb16-pt1
Open

core::num::f16b Rust's 16bit Brain Float#160859
Jamesbarford wants to merge 17 commits into
rust-lang:mainfrom
Jamesbarford:feat/fb16-pt1

Conversation

@Jamesbarford

@Jamesbarford Jamesbarford commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

View all comments

Implements the RFC: f16b type. Best reviewed commit by commit, happy to split into separate PRs if that is deemed easier to review. However the line count and surface area is, in my opinion, reasonably small.

Adds;

  • ABI plumbing for the f16b along with bfloat lang item to work with LLVM, GCC is explicitly unimplemented!(...)
  • f16b feature gate, page for f16b on libruscdoc and a struct bf16 in core::num
  • Tests
  • Treat f16b as a scalar primitive for scalable vectors

Issues;

@rustbot

rustbot commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_attr_ir

cc @jdonszelmann, @JonathanBrouwer

This PR changes rustc_public

cc @oli-obk, @celinval, @ouz-a, @makai410

rustc_codegen_gcc is developed in its own repository. If possible, consider making this change to rust-lang/rustc_codegen_gcc instead.

cc @antoyo, @GuillaumeGomez

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 10, 2026
@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 10, 2026
@rustbot

rustbot commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

r? @jieyouxu

rustbot has assigned @jieyouxu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 75 candidates
  • Random selection from 18 candidates

@rust-log-analyzer

This comment has been minimized.

@jieyouxu

Copy link
Copy Markdown
Member

@rustbot reroll

@rustbot rustbot assigned mati865 and unassigned jieyouxu Aug 10, 2026
}

fn type_f16b(&self) -> Type<'gcc> {
bug!("f16b is not supported by the GCC codegen backend")

@antoyo antoyo Aug 10, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 😄, I will aim to add it in a follow up PR 👍

@rustbot

rustbot commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

rustc_codegen_cranelift is developed in its own repository. If possible, consider making this change to rust-lang/rustc_codegen_cranelift instead.

cc @bjorn3

Comment thread compiler/rustc_ty_utils/src/layout.rs

@bjorn3 bjorn3 Aug 10, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the calling convention of other targets?

View changes since the review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe only these files were changed because they have an exhaustive match on Float.

However, my version of abi-cafe found two interesting failures: GCC and Clang are inconsistent on aarch64 and armv7

// callee, compiled with GCC 12
#include <inttypes.h>
#include <string.h>
#include <stdio.h>
#include <stdbool.h>

typedef struct Many1 {
    __bf16 f0;
} Many1;

void struct_in_1(Many1 arg0) {
    printf("%d", arg0.f0);
}
// caller, compiled with clang 23
#include <inttypes.h>
#include <string.h>
#include <stdio.h>
#include <stdbool.h>

typedef struct Many1 {
    __bf16 f0;
} Many1;

void struct_in_1(Many1 arg0);

void do_test(void) {
    {
        Many1 arg0 = { .f0 = (((union { uint16_t bits; __bf16 value; }){ .bits = 49600 }).value) };

        printf("%d", arg0.f0);
        struct_in_1(arg0);

    }
}

hits

    func struct_in_1's values differed
      values (native-endian hex bytes):
        expect: C0 C1
        caller: C0 C1
        callee: 04 00
      the value was arg0.f0: rustarithmeticty(f16b)
      whose arg was arg0: Many1

The current Rust implementation matches clang, and is hence incompatible with GCC


armv7 with hardware floats also runs into incompatibilities

[target.armv7-unknown-linux-gnueabihf."f16::conv_c::repr_c::clang-nightly_calls_distro-gcc"]
busted = "check"

[target.armv7-unknown-linux-gnueabihf."f16::conv_c::repr_c::distro-gcc_calls_clang-nightly"]
busted = "check"

[target.armv7-unknown-linux-gnueabihf."f16b::conv_c::repr_c::clang-nightly_calls_distro-gcc"]
busted = "check"

[target.armv7-unknown-linux-gnueabihf."f16b::conv_c::repr_c::distro-gcc_calls_clang-nightly"]
busted = "check"

Finally, you can let this ICE on many targets, e.g. mips, powerpc, s390x, sparc

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also (e.g. on loongarch64 https://godbolt.org/z/Y3hdhG4e6) emit a __truncsfbf2 libcall that is not provided (probably needs to be added to compiler-builtins).


I think the ICEs are probably a blocker? That needs a mechanism similar to has_reliable_f128.

@Jamesbarford Jamesbarford Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I added it because of the exhaustive match statement in mips64.rs and sparc64.rs I've removed it; 40d3f6e and put in a panic!(...).

With regard to has_reliable_f128, are you envisaging a has_reliable_f16b entry on TargetConfig?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With regard to has_reliable_f128, are you envisaging a has_reliable_f16b entry on TargetConfig?

Exactly

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's your take on those ABI mismatches? We should track that somewhere.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not particularly certain what mips64 should do.

It doesn't, at least to my knowledge, have hardware support. Given we aren't implementing scalar arithmetic and an f16b can only be created through a bit pattern or vendor intrinsics, I can't immediately see a practical application? Hence a panic! seems like a pragmatic choice for the time being.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No comment on whether this is the right approach, but always use span_bug! or at least bug! where possible in the compiler, rather than panic. It gives much more useful info.

@rust-log-analyzer

This comment has been minimized.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe only these files were changed because they have an exhaustive match on Float.

However, my version of abi-cafe found two interesting failures: GCC and Clang are inconsistent on aarch64 and armv7

// callee, compiled with GCC 12
#include <inttypes.h>
#include <string.h>
#include <stdio.h>
#include <stdbool.h>

typedef struct Many1 {
    __bf16 f0;
} Many1;

void struct_in_1(Many1 arg0) {
    printf("%d", arg0.f0);
}
// caller, compiled with clang 23
#include <inttypes.h>
#include <string.h>
#include <stdio.h>
#include <stdbool.h>

typedef struct Many1 {
    __bf16 f0;
} Many1;

void struct_in_1(Many1 arg0);

void do_test(void) {
    {
        Many1 arg0 = { .f0 = (((union { uint16_t bits; __bf16 value; }){ .bits = 49600 }).value) };

        printf("%d", arg0.f0);
        struct_in_1(arg0);

    }
}

hits

    func struct_in_1's values differed
      values (native-endian hex bytes):
        expect: C0 C1
        caller: C0 C1
        callee: 04 00
      the value was arg0.f0: rustarithmeticty(f16b)
      whose arg was arg0: Many1

The current Rust implementation matches clang, and is hence incompatible with GCC


armv7 with hardware floats also runs into incompatibilities

[target.armv7-unknown-linux-gnueabihf."f16::conv_c::repr_c::clang-nightly_calls_distro-gcc"]
busted = "check"

[target.armv7-unknown-linux-gnueabihf."f16::conv_c::repr_c::distro-gcc_calls_clang-nightly"]
busted = "check"

[target.armv7-unknown-linux-gnueabihf."f16b::conv_c::repr_c::clang-nightly_calls_distro-gcc"]
busted = "check"

[target.armv7-unknown-linux-gnueabihf."f16b::conv_c::repr_c::distro-gcc_calls_clang-nightly"]
busted = "check"

Finally, you can let this ICE on many targets, e.g. mips, powerpc, s390x, sparc

Comment thread library/core/src/num/f16b.rs
},
Primitive::Float(float) => match float {
Float::F16 | Float::F32 => "f32",
Float::F16 | Float::F16B | Float::F32 => "f32",

@folkertdev folkertdev Aug 11, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that right? LLVM just crashes on bf16 right now, so it's probably at least untested?

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could be mistaken, however I don't think WASM supports bf16? I've made it panic!(...) for now; 40d3f6e

Comment thread library/core/src/num/f16b.rs
Comment thread library/core/src/num/f16b.rs
Comment thread tests/codegen-llvm/float/f16b.rs Outdated
@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added the A-test-infra-minicore Area: `minicore` test auxiliary and `//@ add-core-stubs` label Aug 12, 2026
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot

rustbot commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in cfg and check-cfg configuration

cc @Urgau

miri is developed in its own repository. If the Miri part of this change can be broken out, consider making this change to rust-lang/miri instead. However, if Miri needs adjusting for rustc changes, just ignore this message.

cc @rust-lang/miri

@rust-log-analyzer

This comment has been minimized.

@mati865

mati865 commented Aug 12, 2026

Copy link
Copy Markdown
Member

I'm not a good reviewer for this change. Can somebody here pick it up rather than blindly rerolling?

@folkertdev

Copy link
Copy Markdown
Contributor

r? me

#[cfg_attr(feature = "nightly", derive(StableHash))]
pub enum Float {
F16,
F16B,

@RalfJung RalfJung Aug 16, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
F16B,
/// `f16b`. This is not a builtin type in Rust (it is exposed as a lang item),
/// but it is a builtin type in LLVM so needs to be explicitly represented
/// in the backend.
F16B,

View changes since the review

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job x86_64-gnu-gcc failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
---- [ui] tests/ui/abi/rust-cold-works-with-rustic-args.rs stdout ----

error: auxiliary build of /checkout/tests/auxiliary/minicore.rs failed to compile: 
status: exit status: 101
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/auxiliary/minicore.rs" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "-Zcodegen-backend=gcc" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/abi/rust-cold-works-with-rustic-args/libminicore.rlib" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Cpanic=abort" "-Cforce-unwind-tables=yes" "-Clink-dead-code=true" "--crate-type" "rlib" "-Cpanic=abort"
stdout: none
--- stderr -------------------------------
warning: type `c_void` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:443:10
   |
LL | pub enum c_void {
   |          ^^^^^^ help: convert the identifier to upper camel case: `CVoid`
   |
   = note: `#[warn(non_camel_case_types)]` (part of `#[warn(nonstandard_style)]`) on by default

warning: variant `__variant1` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:444:5
   |
LL |     __variant1,
   |     ^^^^^^^^^^ help: convert the identifier to upper camel case: `Variant1`

warning: variant `__variant2` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:445:5
   |
LL |     __variant2,
   |     ^^^^^^^^^^ help: convert the identifier to upper camel case: `Variant2`

warning: type `f16x2` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:494:14
   |
LL |     pub type f16x2 = Simd<f16, 2>;
   |              ^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `F16x2`

warning: type `f16x4` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:495:14
   |
LL |     pub type f16x4 = Simd<f16, 4>;
   |              ^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `F16x4`

warning: type `f16x8` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:496:14
   |
LL |     pub type f16x8 = Simd<f16, 8>;
   |              ^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `F16x8`

warning: type `f16x16` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:497:14
   |
LL |     pub type f16x16 = Simd<f16, 16>;
   |              ^^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `F16x16`

warning: type `f16x32` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:498:14
   |
LL |     pub type f16x32 = Simd<f16, 32>;
   |              ^^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `F16x32`

warning: type `f32x2` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:500:14
   |
LL |     pub type f32x2 = Simd<f32, 2>;
   |              ^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `F32x2`

warning: type `f32x4` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:501:14
   |
LL |     pub type f32x4 = Simd<f32, 4>;
   |              ^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `F32x4`

warning: type `f32x8` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:502:14
   |
LL |     pub type f32x8 = Simd<f32, 8>;
   |              ^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `F32x8`

warning: type `f32x16` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:503:14
   |
LL |     pub type f32x16 = Simd<f32, 16>;
   |              ^^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `F32x16`

warning: type `f32x32` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:504:14
   |
LL |     pub type f32x32 = Simd<f32, 32>;
   |              ^^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `F32x32`

warning: type `f64x1` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:506:14
   |
LL |     pub type f64x1 = Simd<f64, 1>;
   |              ^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `F64x1`

warning: type `f64x2` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:507:14
   |
LL |     pub type f64x2 = Simd<f64, 2>;
   |              ^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `F64x2`

warning: type `f64x4` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:508:14
   |
LL |     pub type f64x4 = Simd<f64, 4>;
   |              ^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `F64x4`

warning: type `f64x8` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:509:14
   |
LL |     pub type f64x8 = Simd<f64, 8>;
   |              ^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `F64x8`

warning: type `i8x8` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:511:14
   |
LL |     pub type i8x8 = Simd<i8, 8>;
   |              ^^^^ help: convert the identifier to upper camel case (notice the capitalization): `I8x8`

warning: type `i8x16` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:512:14
   |
LL |     pub type i8x16 = Simd<i8, 16>;
   |              ^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `I8x16`

warning: type `i8x32` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:513:14
   |
LL |     pub type i8x32 = Simd<i8, 32>;
   |              ^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `I8x32`

warning: type `i8x64` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:514:14
   |
LL |     pub type i8x64 = Simd<i8, 64>;
   |              ^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `I8x64`

warning: type `i16x2` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:516:14
   |
LL |     pub type i16x2 = Simd<i16, 2>;
   |              ^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `I16x2`

warning: type `i16x4` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:517:14
   |
LL |     pub type i16x4 = Simd<i16, 4>;
   |              ^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `I16x4`

warning: type `i16x8` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:518:14
   |
LL |     pub type i16x8 = Simd<i16, 8>;
   |              ^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `I16x8`

warning: type `i16x16` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:519:14
   |
LL |     pub type i16x16 = Simd<i16, 16>;
   |              ^^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `I16x16`

warning: type `i16x32` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:520:14
   |
LL |     pub type i16x32 = Simd<i16, 32>;
   |              ^^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `I16x32`

warning: type `i32x2` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:522:14
   |
LL |     pub type i32x2 = Simd<i32, 2>;
   |              ^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `I32x2`

warning: type `i32x4` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:523:14
   |
LL |     pub type i32x4 = Simd<i32, 4>;
   |              ^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `I32x4`

warning: type `i32x8` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:524:14
   |
LL |     pub type i32x8 = Simd<i32, 8>;
   |              ^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `I32x8`

warning: type `i32x16` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:525:14
   |
LL |     pub type i32x16 = Simd<i32, 16>;
   |              ^^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `I32x16`

warning: type `i64x1` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:527:14
   |
LL |     pub type i64x1 = Simd<i64, 1>;
   |              ^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `I64x1`

warning: type `i64x2` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:528:14
   |
LL |     pub type i64x2 = Simd<i64, 2>;
   |              ^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `I64x2`

warning: type `i64x4` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:529:14
   |
LL |     pub type i64x4 = Simd<i64, 4>;
   |              ^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `I64x4`

warning: type `i64x8` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:530:14
   |
LL |     pub type i64x8 = Simd<i64, 8>;
   |              ^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `I64x8`

warning: type `u8x16` should have an upper camel case name
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:532:14
   |
LL |     pub type u8x16 = Simd<u8, 16>;
   |              ^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `U8x16`

warning: unnecessary transmute
##[warning]  --> /checkout/tests/auxiliary/minicore.rs:427:22
   |
LL |             unsafe { mem::transmute(unchecked_shl(value.to_bits() as u32, 16u32)) }
   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unnecessary_transmutes)]` on by default
help: replace this with
   |
LL -             unsafe { mem::transmute(unchecked_shl(value.to_bits() as u32, 16u32)) }
LL +             unsafe { f32::from_bits(unchecked_shl(value.to_bits() as u32, 16u32)) }
   |

##[error]error: internal compiler error: compiler/rustc_codegen_gcc/src/type_.rs:160:9: f16b is not supported by the GCC codegen backend


thread 'rustc' (26435) panicked at compiler/rustc_codegen_gcc/src/type_.rs:160:9:
Box<dyn Any>
stack backtrace:
   0:     0x7facdc3cf6f1 - <<std[3721c39c1a61ddab]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[8cd92447b067e6d2]::fmt::Display>::fmt
   1:     0x7facdc4161f8 - core[8cd92447b067e6d2]::fmt::write
   2:     0x7facdc3e130c - <std[3721c39c1a61ddab]::sys::stdio::unix::Stderr as core[8cd92447b067e6d2]::io::write::Write>::write_fmt
   3:     0x7facdc393e56 - std[3721c39c1a61ddab]::panicking::default_hook::{closure#0}
   4:     0x7facdc3bc851 - std[3721c39c1a61ddab]::panicking::default_hook
   5:     0x7facd8518b94 - <alloc[b10c1bb71db15024]::boxed::Box<rustc_driver_impl[94a49bd93fdf6e41]::install_ice_hook::{closure#1}> as core[8cd92447b067e6d2]::ops::function::Fn<(&dyn for<'a, 'b> core[8cd92447b067e6d2]::ops::function::Fn<(&'a std[3721c39c1a61ddab]::panic::PanicHookInfo<'b>,), Output = ()> + core[8cd92447b067e6d2]::marker::Sync + core[8cd92447b067e6d2]::marker::Send, &std[3721c39c1a61ddab]::panic::PanicHookInfo)>>::call
   6:     0x7facdc3bcbc2 - std[3721c39c1a61ddab]::panicking::panic_with_hook
   7:     0x7facdc08c85e - std[3721c39c1a61ddab]::panicking::begin_panic::<rustc_errors[2b4e70d5658165f4]::ExplicitBug>::{closure#0}
   8:     0x7facdc08c1ce - std[3721c39c1a61ddab]::sys::backtrace::__rust_end_short_backtrace::<std[3721c39c1a61ddab]::panicking::begin_panic<rustc_errors[2b4e70d5658165f4]::ExplicitBug>::{closure#0}, !>
   9:     0x7facdc06d91b - std[3721c39c1a61ddab]::panicking::begin_panic::<rustc_errors[2b4e70d5658165f4]::ExplicitBug>
  10:     0x7facdc075342 - <rustc_errors[2b4e70d5658165f4]::diagnostic::BugAbort as rustc_errors[2b4e70d5658165f4]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7facdbba92e0 - rustc_middle[6cbf114c12a94516]::util::bug::opt_span_bug_fmt::<rustc_span[52130c75a2d821fc]::span_encoding::Span>::{closure#0}
  12:     0x7facdbba9328 - rustc_middle[6cbf114c12a94516]::ty::context::tls::with_opt::<rustc_middle[6cbf114c12a94516]::util::bug::opt_span_bug_fmt<rustc_span[52130c75a2d821fc]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x7facdbba5280 - rustc_middle[6cbf114c12a94516]::ty::context::tls::with_context_opt::<rustc_middle[6cbf114c12a94516]::ty::context::tls::with_opt<rustc_middle[6cbf114c12a94516]::util::bug::opt_span_bug_fmt<rustc_span[52130c75a2d821fc]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x7facdbbbdce5 - rustc_middle[6cbf114c12a94516]::util::bug::bug_fmt
  15:     0x7facca06521a - <rustc_codegen_gcc[7629a038490706de]::context::CodegenCx as rustc_codegen_ssa[f387042fd4fb1545]::traits::type_::BaseTypeCodegenMethods>::type_f16b
  16:     0x7facca066f0f - <rustc_codegen_gcc[7629a038490706de]::context::CodegenCx as rustc_codegen_ssa[f387042fd4fb1545]::traits::type_::DerivedTypeCodegenMethods>::type_from_float
  17:     0x7facca04a63d - <rustc_abi[d732dcf463e24381]::layout::ty::TyAndLayout<rustc_middle[6cbf114c12a94516]::ty::Ty> as rustc_codegen_gcc[7629a038490706de]::type_of::LayoutGccExt>::gcc_type
  18:     0x7facca02fccd - <rustc_target[7ee5767811797919]::callconv::FnAbi<rustc_middle[6cbf114c12a94516]::ty::Ty> as rustc_codegen_gcc[7629a038490706de]::abi::FnAbiGccExt>::gcc_type
  19:     0x7facca057d21 - <rustc_codegen_gcc[7629a038490706de]::context::CodegenCx>::declare_fn
  20:     0x7facca061d0f - <rustc_codegen_gcc[7629a038490706de]::context::CodegenCx as rustc_codegen_ssa[f387042fd4fb1545]::traits::declare::PreDefineCodegenMethods>::predefine_fn
  21:     0x7facca10892a - <rustc_middle[6cbf114c12a94516]::mono::MonoItem as rustc_codegen_ssa[f387042fd4fb1545]::mono_item::MonoItemExt>::predefine::<rustc_codegen_gcc[7629a038490706de]::builder::Builder>
  22:     0x7facca079705 - rustc_codegen_gcc[7629a038490706de]::base::compile_codegen_unit::module_codegen
  23:     0x7facca075a50 - rustc_codegen_gcc[7629a038490706de]::base::compile_codegen_unit
  24:     0x7facca095b15 - <rustc_codegen_gcc[7629a038490706de]::GccCodegenBackend as rustc_codegen_ssa[f387042fd4fb1545]::traits::backend::CodegenBackend>::codegen_crate
  25:     0x7facd873aa97 - <rustc_session[9244369d6e9dddde]::session::Session>::time::<alloc[b10c1bb71db15024]::boxed::Box<dyn core[8cd92447b067e6d2]::any::Any>, rustc_interface[202d6aa885dde126]::passes::start_codegen::{closure#1}>
  26:     0x7facd86f40f1 - rustc_interface[202d6aa885dde126]::passes::start_codegen
  27:     0x7facd8745d30 - <rustc_interface[202d6aa885dde126]::queries::Linker>::codegen_and_build_linker
  28:     0x7facd8520b04 - <std[3721c39c1a61ddab]::thread::local::LocalKey<core[8cd92447b067e6d2]::cell::Cell<*const ()>>>::with::<rustc_middle[6cbf114c12a94516]::ty::context::tls::enter_context<<rustc_middle[6cbf114c12a94516]::ty::context::GlobalCtxt>::enter<rustc_interface[202d6aa885dde126]::passes::create_and_enter_global_ctxt<core[8cd92447b067e6d2]::option::Option<rustc_interface[202d6aa885dde126]::queries::Linker>, rustc_driver_impl[94a49bd93fdf6e41]::run_compiler::{closure#0}::{closure#1}>::{closure#2}, core[8cd92447b067e6d2]::option::Option<rustc_interface[202d6aa885dde126]::queries::Linker>>::{closure#1}, core[8cd92447b067e6d2]::option::Option<rustc_interface[202d6aa885dde126]::queries::Linker>>::{closure#0}, core[8cd92447b067e6d2]::option::Option<rustc_interface[202d6aa885dde126]::queries::Linker>>
  29:     0x7facd845c583 - <rustc_middle[6cbf114c12a94516]::ty::context::TyCtxt>::create_global_ctxt::<core[8cd92447b067e6d2]::option::Option<rustc_interface[202d6aa885dde126]::queries::Linker>, rustc_interface[202d6aa885dde126]::passes::create_and_enter_global_ctxt<core[8cd92447b067e6d2]::option::Option<rustc_interface[202d6aa885dde126]::queries::Linker>, rustc_driver_impl[94a49bd93fdf6e41]::run_compiler::{closure#0}::{closure#1}>::{closure#2}>
  30:     0x7facd84d7eaa - rustc_interface[202d6aa885dde126]::passes::create_and_enter_global_ctxt::<core[8cd92447b067e6d2]::option::Option<rustc_interface[202d6aa885dde126]::queries::Linker>, rustc_driver_impl[94a49bd93fdf6e41]::run_compiler::{closure#0}::{closure#1}>
  31:     0x7facd8558cb4 - rustc_interface[202d6aa885dde126]::interface::run_compiler::<(), rustc_driver_impl[94a49bd93fdf6e41]::run_compiler::{closure#0}>::{closure#2}
  32:     0x7facd8548a95 - rustc_span[52130c75a2d821fc]::create_session_globals_then::<(), rustc_interface[202d6aa885dde126]::util::run_in_thread_with_globals<rustc_interface[202d6aa885dde126]::util::run_in_thread_pool_with_globals<rustc_interface[202d6aa885dde126]::interface::run_compiler<(), rustc_driver_impl[94a49bd93fdf6e41]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}::{closure#0}>
  33:     0x7facd850ffd8 - std[3721c39c1a61ddab]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[202d6aa885dde126]::util::run_in_thread_with_globals<rustc_interface[202d6aa885dde126]::util::run_in_thread_pool_with_globals<rustc_interface[202d6aa885dde126]::interface::run_compiler<(), rustc_driver_impl[94a49bd93fdf6e41]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  34:     0x7facd852abf3 - <std[3721c39c1a61ddab]::thread::lifecycle::spawn_unchecked<rustc_interface[202d6aa885dde126]::util::run_in_thread_with_globals<rustc_interface[202d6aa885dde126]::util::run_in_thread_pool_with_globals<rustc_interface[202d6aa885dde126]::interface::run_compiler<(), rustc_driver_impl[94a49bd93fdf6e41]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[8cd92447b067e6d2]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  35:     0x7facdc3cbbd9 - <std[3721c39c1a61ddab]::sys::thread::unix::Thread>::new::thread_start
  36:     0x7facd6a6ba83 - <unknown>
  37:     0x7facd6afd890 - <unknown>
  38:                0x0 - <unknown>

note: using internal features is not supported and expected to cause internal compiler errors when used incorrectly

note: please attach the file at `/checkout/obj/rustc-ice-2026-08-18T15_06_22-26429.txt` to your bug report

note: rustc 1.100.0-nightly (9766a60f9 2026-08-18) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z simulate-remapped-rust-src-base=/rustc/FAKE_PREFIX -Z translate-remapped-path-to-local-path=no -Z ignore-directory-in-diagnostics-source-blocks=/cargo -Z ignore-directory-in-diagnostics-source-blocks=/checkout/vendor -Z codegen-backend=gcc -C codegen-units=1 -Z ui-testing -Z deduplicate-diagnostics=no -Z write-long-types-to-disk=no -C strip=debuginfo -C prefer-dynamic -C rpath -C debuginfo=0 -C panic=abort -C force-unwind-tables=yes -C link-dead-code=true --crate-type rlib -C panic=abort

query stack during panic:
end of query stack
error: aborting due to 1 previous error; 36 warnings emitted
------------------------------------------

Important

For more information how to resolve CI failures of this job, visit this link.

@folkertdev

Copy link
Copy Markdown
Contributor

re

##[error]error: internal compiler error: compiler/rustc_codegen_gcc/src/type_.rs:160:9: f16b is not supported by the GCC codegen backend

by delaying adding support you now exclude a bunch of tests from the GCC run that we later need to enable again. I believe hooking it up is actually kind of trivial, so that may be the better call?

PartialEq, sym::eq, eq_trait, Target::Trait, GenericRequirement::Exact(1);
PartialOrd, sym::partial_ord, partial_ord_trait, Target::Trait, GenericRequirement::Exact(1);
CVoid, sym::c_void, c_void, Target::Enum, GenericRequirement::None;
BFloat, sym::bfloat, bfloat_type, Target::Struct, GenericRequirement::Exact(0);

@beetrees beetrees Aug 18, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
BFloat, sym::bfloat, bfloat_type, Target::Struct, GenericRequirement::Exact(0);
F16B, sym::f16b, f16b, Target::Struct, GenericRequirement::Exact(0);

May as well keep the lang item name consistent with the type name.

View changes since the review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-test-infra-minicore Area: `minicore` test auxiliary and `//@ add-core-stubs` S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.